package waitNotifyBlockingQueue;

import java.util.concurrent.ArrayBlockingQueue;

public class Foodie extends Thread{
    static  int full = 10;
    public ArrayBlockingQueue queue;

    public Foodie(ArrayBlockingQueue queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while (true){
            try {
                if(full > 0){
                queue.take();
                full--;
                System.out.println("吃货吃了一碗,还剩" + full + "碗" );
                }else {
                    break;
                }
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
